package com.hjn.springboot.springbootinterceptor.controller;

import com.hjn.springboot.springbootinterceptor.entity.po.User;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
public class IndexController {
    /**
     * 无需用户登录
     *
     * @return
     */
    @RequestMapping(value = "/index")
    public String index() {
        return "INDEX";
    }

    /**
     * 无需用户登录
     *
     * @return
     */
    @RequestMapping(value = "/user/page/login")
    public String loginPage() {
        return "Login Page";
    }

    @RequestMapping(value = "/user/login")
    public String login(HttpServletRequest request) {
        User user = new User();
        user.setUuid(1);
        user.setUserName("lisi");
        request.getSession().setAttribute("user", user);
        return "Logged";
    }

    @RequestMapping(value = "/user/nologin")
    public String nologin(HttpServletRequest request) {
        System.out.println("nologin方法进入");
        return "nologin";
    }

    /**
     * 需要用户是登录状态
     *
     * @return
     */
    @RequestMapping(value = "/user/center")
    public String center() {
        return "User Center";
    }
}